{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "263ca20c-ee81-46ee-afca-f2fd1e5d9a14",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl\n",
    "from perspective.widget import PerspectiveWidget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ade03e76-e173-4b92-ab8d-dde7deeb2411",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.read_parquet(\"new_share.parqurt\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "86eaca15-d717-4270-981b-4730006163fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = pl.read_parquet(\"stock_basic.parquet\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "960df94f-e61f-48fb-9a96-39dc1611b3bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1=d1.with_columns(\n",
    "    ipo_date=pl.col.ipo_date.str.to_date(\"%Y%m%d\"),\n",
    "    issue_date=pl.col.issue_date.str.to_date(\"%Y%m%d\"),\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "1bde9197-4ee0-4293-8f92-171e94b05b7c",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2=d2.with_columns(\n",
    "    list_date=pl.col.list_date.str.to_date(\"%Y%m%d\"),\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2947e2c9-9e0a-4050-b632-33cde0560db0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "67ec46b9c86b4ae087df9a83f4dbad86",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(d1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e67f0d7b-ebc4-440d-b058-8e0ca51c15b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "43bc65a3eace40b9b436b4ab9d2e533d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'symbol', 'name', 'area', 'industry', 'cnspell', …"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(d2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1fa1f3e6-9f6d-4e24-a477-ac980886d466",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2_000, 21)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>ts_code</th><th>sub_code</th><th>name</th><th>ipo_date</th><th>issue_date</th><th>amount</th><th>market_amount</th><th>price</th><th>pe</th><th>limit_amount</th><th>funds</th><th>ballot</th><th>symbol</th><th>name_right</th><th>area</th><th>industry</th><th>cnspell</th><th>market</th><th>list_date</th><th>act_name</th><th>act_ent_type</th></tr><tr><td>str</td><td>str</td><td>str</td><td>date</td><td>date</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>date</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;301636.SZ&quot;</td><td>&quot;301636&quot;</td><td>&quot;泽润新能&quot;</td><td>2025-04-28</td><td>null</td><td>1597.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.45</td><td>0.0</td><td>0.0</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;001400.SZ&quot;</td><td>&quot;001400&quot;</td><td>&quot;江顺科技&quot;</td><td>2025-04-15</td><td>2025-04-24</td><td>1500.0</td><td>1500.0</td><td>37.36</td><td>15.32</td><td>1.5</td><td>5.604</td><td>0.01</td><td>&quot;001400&quot;</td><td>&quot;江顺科技&quot;</td><td>&quot;江苏&quot;</td><td>&quot;专用机械&quot;</td><td>&quot;jskj&quot;</td><td>&quot;主板&quot;</td><td>2025-04-24</td><td>null</td><td>null</td></tr><tr><td>&quot;301560.SZ&quot;</td><td>&quot;301560&quot;</td><td>&quot;众捷汽车&quot;</td><td>2025-04-15</td><td>null</td><td>3040.0</td><td>1216.0</td><td>16.5</td><td>21.3</td><td>0.7</td><td>5.016</td><td>0.02</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td><td>null</td></tr><tr><td>&quot;603202.SH&quot;</td><td>&quot;732202&quot;</td><td>&quot;天有为&quot;</td><td>2025-04-14</td><td>2025-04-24</td><td>4000.0</td><td>2611.0</td><td>93.5</td><td>13.5</td><td>1.25</td><td>37.4</td><td>0.03</td><td>&quot;603202&quot;</td><td>&quot;天有为&quot;</td><td>&quot;黑龙江&quot;</td><td>&quot;汽车配件&quot;</td><td>&quot;tyw&quot;</td><td>&quot;主板&quot;</td><td>2025-04-24</td><td>null</td><td>null</td></tr><tr><td>&quot;301662.SZ&quot;</td><td>&quot;301662&quot;</td><td>&quot;宏工科技&quot;</td><td>2025-04-08</td><td>2025-04-17</td><td>2000.0</td><td>813.0</td><td>26.6</td><td>7.05</td><td>0.45</td><td>5.32</td><td>0.02</td><td>&quot;301662&quot;</td><td>&quot;C宏工&quot;</td><td>&quot;广东&quot;</td><td>&quot;专用机械&quot;</td><td>&quot;hgkj&quot;</td><td>&quot;创业板&quot;</td><td>2025-04-17</td><td>null</td><td>null</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;002953.SZ&quot;</td><td>&quot;002953&quot;</td><td>&quot;日丰股份&quot;</td><td>2019-04-24</td><td>2019-05-09</td><td>4302.0</td><td>3872.0</td><td>10.52</td><td>16.34</td><td>1.7</td><td>4.526</td><td>0.03</td><td>&quot;002953&quot;</td><td>&quot;日丰股份&quot;</td><td>&quot;广东&quot;</td><td>&quot;电气设备&quot;</td><td>&quot;rfgf&quot;</td><td>&quot;主板&quot;</td><td>2019-05-09</td><td>&quot;冯就景&quot;</td><td>&quot;民营企业&quot;</td></tr><tr><td>&quot;603697.SH&quot;</td><td>&quot;732697&quot;</td><td>&quot;有友食品&quot;</td><td>2019-04-23</td><td>2019-05-08</td><td>7950.0</td><td>7155.0</td><td>7.87</td><td>13.92</td><td>3.1</td><td>6.257</td><td>0.05</td><td>&quot;603697&quot;</td><td>&quot;有友食品&quot;</td><td>&quot;重庆&quot;</td><td>&quot;食品&quot;</td><td>&quot;yysp&quot;</td><td>&quot;主板&quot;</td><td>2019-05-08</td><td>null</td><td>null</td></tr><tr><td>&quot;300772.SZ&quot;</td><td>&quot;300772&quot;</td><td>&quot;运达股份&quot;</td><td>2019-04-17</td><td>2019-04-26</td><td>7349.0</td><td>6614.0</td><td>6.52</td><td>22.97</td><td>2.8</td><td>4.792</td><td>0.04</td><td>&quot;300772&quot;</td><td>&quot;运达股份&quot;</td><td>&quot;浙江&quot;</td><td>&quot;电气设备&quot;</td><td>&quot;ydgf&quot;</td><td>&quot;创业板&quot;</td><td>2019-04-26</td><td>null</td><td>null</td></tr><tr><td>&quot;603967.SH&quot;</td><td>&quot;732967&quot;</td><td>&quot;中创物流&quot;</td><td>2019-04-17</td><td>2019-04-29</td><td>6667.0</td><td>6000.0</td><td>15.32</td><td>22.24</td><td>2.6</td><td>10.213</td><td>0.04</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;山东&quot;</td><td>&quot;仓储物流&quot;</td><td>&quot;zcwl&quot;</td><td>&quot;主板&quot;</td><td>2019-04-29</td><td>null</td><td>null</td></tr><tr><td>&quot;300773.SZ&quot;</td><td>&quot;300773&quot;</td><td>&quot;拉卡拉&quot;</td><td>2019-04-16</td><td>2019-04-25</td><td>4001.0</td><td>3601.0</td><td>33.28</td><td>22.99</td><td>1.2</td><td>13.315</td><td>0.04</td><td>&quot;300773&quot;</td><td>&quot;拉卡拉&quot;</td><td>&quot;北京&quot;</td><td>&quot;软件服务&quot;</td><td>&quot;lkl&quot;</td><td>&quot;创业板&quot;</td><td>2019-04-25</td><td>null</td><td>null</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2_000, 21)\n",
       "┌───────────┬──────────┬──────────┬────────────┬───┬────────┬────────────┬──────────┬──────────────┐\n",
       "│ ts_code   ┆ sub_code ┆ name     ┆ ipo_date   ┆ … ┆ market ┆ list_date  ┆ act_name ┆ act_ent_type │\n",
       "│ ---       ┆ ---      ┆ ---      ┆ ---        ┆   ┆ ---    ┆ ---        ┆ ---      ┆ ---          │\n",
       "│ str       ┆ str      ┆ str      ┆ date       ┆   ┆ str    ┆ date       ┆ str      ┆ str          │\n",
       "╞═══════════╪══════════╪══════════╪════════════╪═══╪════════╪════════════╪══════════╪══════════════╡\n",
       "│ 301636.SZ ┆ 301636   ┆ 泽润新能 ┆ 2025-04-28 ┆ … ┆ null   ┆ null       ┆ null     ┆ null         │\n",
       "│ 001400.SZ ┆ 001400   ┆ 江顺科技 ┆ 2025-04-15 ┆ … ┆ 主板   ┆ 2025-04-24 ┆ null     ┆ null         │\n",
       "│ 301560.SZ ┆ 301560   ┆ 众捷汽车 ┆ 2025-04-15 ┆ … ┆ null   ┆ null       ┆ null     ┆ null         │\n",
       "│ 603202.SH ┆ 732202   ┆ 天有为   ┆ 2025-04-14 ┆ … ┆ 主板   ┆ 2025-04-24 ┆ null     ┆ null         │\n",
       "│ 301662.SZ ┆ 301662   ┆ 宏工科技 ┆ 2025-04-08 ┆ … ┆ 创业板 ┆ 2025-04-17 ┆ null     ┆ null         │\n",
       "│ …         ┆ …        ┆ …        ┆ …          ┆ … ┆ …      ┆ …          ┆ …        ┆ …            │\n",
       "│ 002953.SZ ┆ 002953   ┆ 日丰股份 ┆ 2019-04-24 ┆ … ┆ 主板   ┆ 2019-05-09 ┆ 冯就景   ┆ 民营企业     │\n",
       "│ 603697.SH ┆ 732697   ┆ 有友食品 ┆ 2019-04-23 ┆ … ┆ 主板   ┆ 2019-05-08 ┆ null     ┆ null         │\n",
       "│ 300772.SZ ┆ 300772   ┆ 运达股份 ┆ 2019-04-17 ┆ … ┆ 创业板 ┆ 2019-04-26 ┆ null     ┆ null         │\n",
       "│ 603967.SH ┆ 732967   ┆ 中创物流 ┆ 2019-04-17 ┆ … ┆ 主板   ┆ 2019-04-29 ┆ null     ┆ null         │\n",
       "│ 300773.SZ ┆ 300773   ┆ 拉卡拉   ┆ 2019-04-16 ┆ … ┆ 创业板 ┆ 2019-04-25 ┆ null     ┆ null         │\n",
       "└───────────┴──────────┴──────────┴────────────┴───┴────────┴────────────┴──────────┴──────────────┘"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = d1.join(d2, on=\"ts_code\", how=\"left\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3610198a-02e1-47e2-a9c3-ff10aa500629",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1658e48f62cc430394e79edfaaa26ba0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "f2350359-d3e1-40a3-9b78-20e5a5903459",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "5173a26037cf482da81f0a66af400a8b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b34ebe49-fb94-4f22-9459-fcd734df965a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "ebbe25e4a31d4970bb602e11b12ba7bc",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "b441c5fe-bb42-47ef-afa6-240e0a1fe1d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a43b1c204ef2442a8ac685b00634c243",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "PerspectiveWidget(binding_mode='server', columns=['ts_code', 'sub_code', 'name', 'ipo_date', 'issue_date', 'am…"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "PerspectiveWidget(df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f13bff40-1e36-43bf-aba3-f22c07d1b406",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
